package com.yuda.campsite.mapper;

import com.yuda.campsite.domain.CampsiteDistribution;

import java.util.List;
import com.yuda.campsite.domain.CampsiteDistribution;
import com.yuda.campsite.domain.SpartaLog;
import org.apache.ibatis.annotations.Select;

/**
 * 【请填写功能名称】Mapper接口
 *
 * @author wyn
 * @date 2021-12-09
 */
public interface CampsiteDistributionMapper
{
    /**
     * 查询【请填写功能名称】
     *
     * @param uuid 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    public CampsiteDistribution selectCampsiteDistributionById(String uuid);

    /**
     * 查询【请填写功能名称】列表
     *
     * @param campsiteDistribution 【请填写功能名称】
     * @return 【请填写功能名称】集合
     */
    public List<CampsiteDistribution> selectCampsiteDistributionList(CampsiteDistribution campsiteDistribution);

    /**
     * 新增【请填写功能名称】
     *
     * @param campsiteDistribution 【请填写功能名称】
     * @return 结果
     */
    public int insertCampsiteDistribution(CampsiteDistribution campsiteDistribution);

    /**
     * 修改【请填写功能名称】
     *
     * @param campsiteDistribution 【请填写功能名称】
     * @return 结果
     */
    public int updateCampsiteDistribution(CampsiteDistribution campsiteDistribution);

    /**
     * 删除【请填写功能名称】
     *
     * @param uuid 【请填写功能名称】ID
     * @return 结果
     */
    public int deleteCampsiteDistributionById(String uuid);

    /**
     * 批量删除【请填写功能名称】
     *
     * @param uuids 需要删除的数据ID
     * @return 结果
     */
    public int deleteCampsiteDistributionByIds(String[] uuids);

    @Select("select a.message,from_unixtime(a.time, '%Y-%m-%d %H:%i:%s') as time,b.id_card as idCard,b.name as studentName,b.phone,c.name as campName,d.name as distributeName from (\n" +
            "\tSELECT message,time,student_id,identity,code from sparta_log where length(code)>10 and student_id is not null ORDER BY time,student_id ) a\n" +
            "\tLEFT JOIN student_info b on a.student_id = b.uuid\n" +
            "\tLEFT JOIN campsite_conf c on c.identity = a.identity\n" +
            "\tLEFT JOIN campsite_distribution d on d.camp_id = c.id where c.id=#{campsiteId} and a.code = d.uuid")
    List<SpartaLog> selectDistributionLogs(Integer campsiteId);

}
